
/**************************************************************************************************************
 **author:xiezh
 **date:2020-6-4
 **控制程序，接收通过udp发来的指令控制小车
 **端口号6666
 **************************************************************************************************************/
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <errno.h>

#include <ros/ros.h>
#include "std_msgs/String.h"
#include <sstream>

#define PORT 6666

static std_msgs::String g_msg;
void callback(const std_msgs::String::ConstPtr & msg)
{
    g_msg = *msg;
}


int main(int argc, char **argv)
{
	ros::init(argc, argv, "controller");
	ros::NodeHandle n,n_para("~");
	ros::Publisher pub = n.advertise<std_msgs::String>("/ctrl/client",1);
	ros::Subscriber sub = n.subscribe("/ctrl/server",1,callback);
	

	while(ros::ok())
	{
		ros::spinOnce();
		pub.publish(g_msg);
	}
	return 0;
_out:
	return -1;
}
